package com.suneast.suneaststore.modules.personal.collect.adapter;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.bean.personal.collect.CollectGoodsBean;
import com.suneast.suneaststore.ui.customview.ZzCheckBox;

public class CollectGoodsAdapter extends BaseQuickAdapter<CollectGoodsBean, CollectGoodsAdapter.VH> {

    private boolean showCheckBox;

    public void setShowCheckBox(boolean showCheckBox) {
        this.showCheckBox = showCheckBox;
    }

    public CollectGoodsAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(VH helper, CollectGoodsBean item) {
        ZzCheckBox checkBox = helper.getView(R.id.cb_select);
        checkBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE);
        Glide.with(helper.itemView.getContext()).load(item.getThumb())
                .into((ImageView) helper.getView(R.id.iv_goods));
        helper.setText(R.id.tv_goods_name, item.getTitle())
                .setText(R.id.tv_goods_price, "¥" + item.getD2_price())
                .addOnClickListener(R.id.btn_go_to_detail);
    }

    public static class VH extends BaseViewHolder {
        public VH(View view) {
            super(view);
        }
    }
}
